package com.wswy.wyjk;

import android.text.TextUtils;

import com.tencent.bugly.Bugly;
import com.tencent.bugly.BuglyStrategy;
import com.tencent.bugly.beta.Beta;
import com.wswy.wyjk.ui.uitls.ChannelManager;

public class UpgradeConfigure {

  private static final String TAG = "UpgradeConfigure";

  public static void init(BasePartyAppContext context){

    Beta.enableHotfix = false;
    Beta.canAutoDownloadPatch = true;
    Beta.canAutoPatch = true;
    Beta.canNotifyUserRestart = true;

    Beta.canShowApkInfo = false;
    Beta.autoDownloadOnWifi = true;


    BuglyStrategy strategy = new BuglyStrategy();
    strategy.setEnableANRCrashMonitor(false);
    strategy.setEnableNativeCrashMonitor(false);

    String channel = ChannelManager.getChannel();
    if (!TextUtils.isEmpty(channel)){
      strategy.setAppChannel(channel);
    }

    if (context.isDebug()){
      Bugly.setIsDevelopmentDevice(context,true);
    }

    String appKey = context.getAppKey(BasePartyAppContext.ConfigureKeys.BUGLY_APPID);
    if (!TextUtils.isEmpty(appKey)){
      Bugly.init(context, appKey,context.isDebug(),strategy);
    }
  }



  public static void installTinker(){
    try {
      Beta.installTinker();
    }catch (Throwable e){
      e.printStackTrace();
    }
  }

}
